import org.junit.Test;

public class Mytest {
    @Test
    public void test1(){
        //int[] arr={1,2,3,4,5};
        int[] arr=new int[10000];
        for(int i=0;i<arr.length;i++){
            arr[i]=i;
        }
        quickSorting(arr, 0, arr.length-1);
        for(int i:arr){
            System.out.print(i+" ");
        }
    }
    private void quickSorting(int[] arr,int left,int right){
        if(right-left<=1) return;
        if(right-left==2){
            if(arr[left]<arr[right]){
                int temp=arr[left];
                arr[left]=arr[right];
                arr[right]=temp;
                return;
            }else{
                return;
            }
        }
        int center=(left+right)/2;
        while(left<right){
            if(arr[left]<arr[center]&&arr[right]>arr[center]){
                int temp=arr[left];
                arr[left]=arr[right];
                arr[right]=temp;
                left++;
                right--;
            }else if(arr[left]>=arr[center]&&arr[right]>arr[center]){
                left++;
            }else if(arr[left]<arr[center]&&arr[right]<=arr[center]){
                right--;
            }else{
                left++;
                right--;
            }
        }
        quickSorting(arr, left,center-1);
        quickSorting(arr, center, right);
    }
}
